Line data Source code
1 : #include "CleaningController.hpp"
2 : #include "ICleaningMotor.hpp"
3 : #include "CleaningLevel.hpp"
4 :
5 64 : CleaningController::CleaningController(ICleaningMotor& motor, int timerDurationMs)
6 64 : : motor_(motor), timer_(*this, timerDurationMs), boosting_(false) {}
7 :
8 41 : void CleaningController::startCleaning() {
9 41 : timer_.stop(); // 진행 중인 HIGH 타이머 취소
10 41 : boosting_ = false; // boost 상태 해제 → 다음 dustDetected()가 HIGH 재활성화 가능
11 41 : motor_.startCleaning(CleaningLevel::NORMAL);
12 41 : }
13 :
14 23 : void CleaningController::stopCleaning() {
15 23 : timer_.stop(); // 진행 중인 HIGH 타이머 취소
16 23 : boosting_ = false;
17 23 : motor_.stopCleaning();
18 23 : }
19 :
20 7 : void CleaningController::boostCleaning() {
21 7 : if (boosting_) {
22 1 : timer_.reset();
23 1 : } else {
24 6 : boosting_ = true;
25 6 : motor_.startCleaning(CleaningLevel::HIGH);
26 6 : timer_.start();
27 : }
28 7 : }
29 :
30 2 : void CleaningController::onExpired() {
31 2 : boosting_ = false;
32 2 : motor_.startCleaning(CleaningLevel::NORMAL);
33 2 : }
|